--TEST--
bool MySQLndUhConnection::setServerOption(resource $connection, int $option)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function setServerOption($res, $option) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::setServerOption($res, $option));
			var_dump(server_option_to_string($option));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function setServerOption($res, $option) {
			return true;
		}
	}

	class proxy3 extends MySQLndUhConnection {
		public function setServerOption($res, $option) {
			return $option;
		}
	}

	class proxy4 extends MySQLndUhConnection {
		public function setServerOption($res, $option) {}
	}

	function server_option_to_string($option) {
		$ret = 'unknown';
		switch ($option) {
			case MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON:
				$ret = 'MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON';
				break;
			case MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_OFF:
				$ret = 'MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON';
				break;
		}
		return $ret;
	}

	function multi_query($conn, $offset, $query) {
		if (!$conn->multi_query($query)) {
			printf("[%03d + 1] [%d] '%s' (%s)\n", $offset, $conn->errno, $conn->error, $query);
			return false;
		}

		printf("Results for %d (%s)\n", $offset, $query);
		do {
			if ($res = $conn->store_result()) {
				while ($row = $res->fetch_assoc())
					var_dump($row);
				$res->close();
			}
		} while ($conn->more_results() && $conn->next_result());
		return true;
	}

	$conn = mysqlnd_uh_test\connect::mysqli(MYSQLND_UH_TEST_MYSQL_HOST, MYSQLND_UH_TEST_MYSQL_PORT,
		MYSQLND_UH_TEST_MYSQL_USER, MYSQLND_UH_TEST_MYSQL_PASSWD,
		MYSQLND_UH_TEST_MYSQL_DB, MYSQLND_UH_TEST_MYSQL_SOCKET, false, MYSQLI_CLIENT_FOUND_ROWS);
	multi_query($conn, 1, "SELECT 'without'; SELECT 'proxy'");
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());
	$conn = mysqlnd_uh_test\connect::mysqli();
	multi_query($conn, 2, "SELECT 'with'; SELECT 'proxy'");
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy2());
	multi_query($conn, 3, "SELECT 'with'; SELECT 'proxy2'");
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy3());
	multi_query($conn, 4, "SELECT 'with'; SELECT 'proxy3'");
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy4());
	multi_query($conn, 5, "SELECT 'with'; SELECT 'proxy4'");
	mysqlnd_uh_test\query_test::mysqli($conn);

	print "done!";
?>
--EXPECTF--
Results for 1 (SELECT 'without'; SELECT 'proxy')
array(1) {
  ["without"]=>
  string(7) "without"
}
array(1) {
  ["proxy"]=>
  string(5) "proxy"
}
proxy::setServerOption(array (
  0 => NULL,
  1 => 0,
))
bool(true)
string(44) "MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON"
Results for 2 (SELECT 'with'; SELECT 'proxy')
array(1) {
  ["with"]=>
  string(4) "with"
}
array(1) {
  ["proxy"]=>
  string(5) "proxy"
}
proxy::setServerOption(array (
  0 => NULL,
  1 => 1,
))
bool(true)
string(44) "MYSQLND_UH_SERVER_OPTION_MULTI_STATEMENTS_ON"
[003 + 1] [%d] '%s' at line 1' (SELECT 'with'; SELECT 'proxy2')

Warning: mysqli::multi_query(): (MySQLnd User Handler) The method MySQLndUhConnection::setSeverOption() did not return a boolean value as it should in %s on line %d

Warning: mysqli::multi_query(): (MySQLnd User Handler) The method MySQLndUhConnection::setSeverOption() did not return a boolean value as it should in %s on line %d
[004 + 1] [%d] '%s' (SELECT 'with'; SELECT 'proxy3')

Warning: mysqli::multi_query(): (MySQLnd User Handler) The method MySQLndUhConnection::setSeverOption() did not return a boolean value as it should in %s on line %d

Warning: mysqli::multi_query(): (MySQLnd User Handler) The method MySQLndUhConnection::setSeverOption() did not return a boolean value as it should in %s on line %d
[005 + 1] [%d] '%s' at line 1' (SELECT 'with'; SELECT 'proxy4')
done!